package com.example.tabtest;

import android.app.TabActivity;
import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TabHost;
import android.widget.TabHost.TabSpec;

public class MainActivity extends TabActivity {


	TabHost mTabHost;
	

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.tab);

		
		mTabHost = (TabHost) findViewById(android.R.id.tabhost);

		TabSpec spec1 = mTabHost.newTabSpec("tab1");
		TabSpec spec2 = mTabHost.newTabSpec("tab2");
		TabSpec spec3 = mTabHost.newTabSpec("tab3");
		TabSpec spec4 = mTabHost.newTabSpec("tab4");

		LayoutInflater vi1 = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		LayoutInflater vi2 = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		LayoutInflater vi3 = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		LayoutInflater vi4 = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);

		View View_1 = (View) vi1.inflate(R.layout.tab_row_item, null);
		View View_2 = (View) vi2.inflate(R.layout.tab_row_item, null);
		View View_3 = (View) vi3.inflate(R.layout.tab_row_item, null);
		View View_4 = (View) vi4.inflate(R.layout.tab_row_item, null);

		LinearLayout Layout_1 = (LinearLayout) View_1
				.findViewById(R.id.LinearLayout01);
		LinearLayout Layout_2 = (LinearLayout) View_2
				.findViewById(R.id.LinearLayout01);
		LinearLayout Layout_3 = (LinearLayout) View_3
				.findViewById(R.id.LinearLayout01);
		LinearLayout Layout_4 = (LinearLayout) View_4
				.findViewById(R.id.LinearLayout01);

		Layout_1.setBackgroundResource(R.drawable.tab1);
		Layout_2.setBackgroundResource(R.drawable.tab2);
		Layout_3.setBackgroundResource(R.drawable.tab3);
		Layout_4.setBackgroundResource(R.drawable.tab4);

		spec1.setIndicator(View_1);
		spec1.setContent(new Intent(MainActivity.this, a.class));
		spec2.setIndicator(View_2);
		spec2.setContent(new Intent(MainActivity.this, b.class));
		spec3.setIndicator(View_3);
		spec3.setContent(new Intent(MainActivity.this, c.class));
		spec4.setIndicator(View_4);
		spec4.setContent(new Intent(MainActivity.this, d.class));

		mTabHost.addTab(spec1);
		mTabHost.addTab(spec2);
		mTabHost.addTab(spec3);
		mTabHost.addTab(spec4);
		
		mTabHost.getTabWidget().setCurrentTab(0);



	}


}
